<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>考试管理列表</title>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <script src="/bootstrap/js/jquery.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th, td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="panel panel-success">
        <div class="panel-heading panel-title text-center">
            <h1>考试管理列表</h1>
            <form action="" method="post">
                <div style="display: flex;">
<%--                    <input type="text" style="width: 80px" name="username" value="${param.username}" class="form-control" placeholder="用户名..." >--%>
<%--                    <input type="text" style="width:150px" name="phone" value="${param.phone}" class="form-control" placeholder="📱手机号..." >--%>
<%--                    <button type="submit" class="btn btn-primary glyphicon glyphicon-search" >搜索</button>--%>
                </div>
            </form>
        </div>
        <div class="panel-body">
            <table>
                <tr>
                    <th>试卷ID</th>
                    <th>考试名称</th>
                    <th>考试描述</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>状态</th>
                    <th>创建人</th>
                    <th>创建时间</th>
                    <th>操作</th>
                    <th><button onclick="add()" >添加</button></th>
                </tr>
                    <%-- 使用JSP标签循环遍历并渲染exam数据 --%>
                    <c:forEach var="exam" items="${examList}">
                        <tr>
                            <td>${exam.paperId}</td>
                            <td>${exam.title}</td>
                            <td>${exam.intro}</td>
                            <td>${fn:substring(exam.startTime,0,16)}</td>
                            <td>${fn:substring(exam.endTime,0,16)}</td>
                            <td>${exam.state==null?null:(exam.state =="0")?"未开始":(exam.state =="1")?"已开始":"已结束"}</td>
                            <td>${exam.userId}</td>
                            <td>${fn:substring(exam.createTime,0,16)}</td>
                            <td><button onclick="update(${exam.id})">修改</button></td>
                        </tr>
                    </c:forEach>
                <tr>
<%--                    <td colspan="8" class="text-center">--%>
<%--                        <ul class="pagination ">--%>
<%--                            <c:if test="${page.totalCount>0}">--%>
<%--                                总${page.totalCount}条  每页${page.pageLimit}条--%>
<%--                                &lt;%&ndash; <c:forEach begin="1" step="1" end="${page.totalPage}" var="p">--%>
<%--                                     <li><a href="javascript:gotoPage(${p})">${p}</a></li>--%>
<%--                                 </c:forEach>&ndash;%&gt;--%>
<%--                                <a href="${pageContext.request.contextPath}/${page.url}?currtPage=${page.currtPage-1}${page.params}">上一页</a>  <a href="${pageContext.request.contextPath}/${page.url}?currtPage=${page.currtPage+1}${page.params}">下一页</a>--%>
<%--                            </c:if>--%>
<%--                            <c:if test="${page.totalCount<=0}">--%>
<%--                                对不起，暂无数据--%>
<%--                            </c:if>--%>

                        </ul>
                    </td>
                </tr>
            </table>
        </div>
        <div class="panel-footer text-right">
            百度在线考试平台
        </div>
    </div>
</div>
</body>
<script>
    function add(){
        location.href="/exams/addExams";
    }
    function update(id){
        location.href="/exams/updateExams/"+id;
    }
</script>
</html>
